<?php

define ( 'RAPIDLEECH', 'yes' );

define ( 'CONFIG_DIR', 'configs/' );

require_once(CONFIG_DIR.'setup.php');

define ( 'TEMPLATE_DIR', 'templates/'.$options['template_used'].'/' );

require_once('classes/other.php');

?>

<HTML>

<HEAD><TITLE>Video Thumbnail Generator</TITLE></HEAD>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link title="Rapidleech Style" href="templates/plugmod/styles/rl_style_pm.css" rel="stylesheet" type="text/css" />

<BODY>

<center><img src="templates/plugmod/images/logo_pm.gif" alt="RapidLeech PlugMod" border="0" /></center><br />

</BODY>

</HTML>

<center><h2>Video Thumbnail Generator</h2></center>

<?PHP putenv('GDFONTPATH=' . realpath('.')); ?>

<FORM method="post"><center>

<TABLE><td>Video File : 

<select name="video">

<?php

$exts=array(".3gp", ".3g2", ".asf", ".avi", ".dat", ".divx", ".dsm", ".evo", ".flv", ".m1v", ".m2ts", ".m2v", ".m4a", ".mj2", ".mjpg", ".mjpeg", ".mkv", ".mov", ".moov", ".mp4", ".mpg", ".mpeg", ".mpv", ".nut", ".ogg", ".ogm", ".qt", ".swf", ".ts", ".vob", ".wmv", ".xvid", ".tp");

$ext="";

function vidlist($dir) 

{

$results = array();

$handler = opendir($dir);

while ($file = readdir($handler)) 

{

if (strrchr($file,'.')!="")

{

$ext=strtolower(strrchr($file,'.'));

}

if ($file != '.' && $file != '..' && in_array($ext,$GLOBALS["exts"]))

{

$results[] = $file;

}

}

closedir($handler);

sort($results);

return $results;

}

function Output($command) {

$output = array($command);

exec($command.' 2>&1', $output);

return ($output);

}

$files = vidlist("./files");

foreach($files as $file)

{

	echo '<option value="'.$file.'">'.$file.'</option>';

}

?>

<td colspan=2><center><input type=submit value=Generate /></td>

<tr>

</TABLE>

</FORM>

<?PHP

if ($_POST['video']!="")

{

	if ($_POST['all']=="true")

	{

	$video = $options['download_dir'];

	}

	else

	{

		$video=array();		

		$video[0] = $_POST['video'];

	}

foreach ($video as $vdo)

{

	$cmd=getcwd()."/mnt";

        $cmd.=" -ftahomabd.ttf -b0.60 -B0.0 -FFFFF00:10 -k000000 -h100 -c5 -r3 '".$options['download_dir'].$vdo."'";

        Output($cmd);

	$ext=strtolower(strrchr($vdo,'.'));

	$vdofile=str_ireplace($ext,"_s.jpg",$vdo);

        if (file_exists($options['download_dir']."$vdofile"))

	{

         unlink($vdofile);	

         $image = $options['download_dir']."$vdofile";

         echo "<h3>ScreenShot of $vdo</h3><br>";

         print	"<img src=\"$image\">";

         echo '<BR><BR>Download link :';

         echo '<a href="files/'.$vdo.'"> '.$vdo.'</a><BR />';

	}

	else

	{

		echo '<BR />Error in generating ScreenShot of <b><i>'.$vdo.'</i></b> <BR />';

	}

}



}

print "<center><br><br><a href=\"index.php\">Go back to Home</a>";



?>